package yunjiao.javatutorials.apache.kafka;

import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * 日志生成
 *
 * @author yangyunjiao
 */
@Slf4j
@Component
public class LogMessageGenerator {
    AtomicInteger count = new AtomicInteger(1);

    @Scheduled(fixedDelay = 3000L)
    void info() {

        int index = count.getAndIncrement();
        log.info(">>> Log message generated: INFO-" + index);
    }

    @Scheduled(fixedDelay = 4000L)
    void debug() {

        int index = count.getAndIncrement();
        log.debug(">>> Log message generated: DEBUG-" + index);
    }

    @Scheduled(fixedDelay = 5000L)
    void error() {

        int index = count.getAndIncrement();
        log.error(">>> Log message generated: ERROR-" + index);
    }
}
